package dgut.haitaobao.config;

import dgut.haitaobao.interceptor.CheckTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*将拦截器交给spring去管理*/
@Configuration
public class InterceptorConfig  implements WebMvcConfigurer {

    @Autowired
    private CheckTokenInterceptor checkTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkTokenInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/user/**")
                .excludePathPatterns("/product/**")
                .excludePathPatterns("/index/**")
                .excludePathPatterns("/shoppingCart/**")
                .excludePathPatterns("/order/**")
                .excludePathPatterns("/productParams/**");
    }
}
